

set more off 
cap log close 
clear all
set niceness 10 
cap set processor 8
set scheme s1color 
*** Paths ****
gl path1 = "/Users/Wei/Dropbox/Census"
gl path2 = "/Users/Wei/Dropbox/Fertility/Workingdata"
gl path3 = "/Users/Wei/Dropbox/Fertility/Results"
gl path4 = "/Users/Wei/Dropbox/Fertility/Figures"

log using "$path3/Figures.log", replace 

* Figure 1, Figure 2, Figure 3; 
* Figure C1, Figure C2 and Figure C3. Figure C6 

******* *Figure 1 *******

use "$path2/marr_policy", clear
gen mort_rate = 100 -sur_rate if women == 1 
egen fine_6_20 = rowmean(fine_age6-fine_age20)

keep if  han & age >= 25  
keep if year_birth <= 1980 & year_birth >= 1940 

recode year_birth (1940/1949 = -1) (1950/1959 = 0) (1960/1969 = 1) (1970/1980 = 2), gen(period)
tab period [aw =wt], su(senior)
gen female = women
collapse senior college work   [aw = wt], by(period female)

label define period -1 "1940-1949" 0 "1950-1959" 1 "1960-1969" 2 "1970-1980"
label value period period 
label var period "Birth Cohorts"
drop work 

reshape wide senior college , i(period) j(female)

gr bar senior0 senior1 college0 college1, over(period) legend(order(2 1 4 3) label(1 "Men of Han (Senior high)") label(2 "Women of Han (Senior high)") label(3 "Men of Han (College)") label(4 "Women of Han (College)") ring(0) pos(11)) ///
 blabel(total, format(%5.1g))  ytit("Completion rate") ylabel(0(0.05)0.35) 
 gr export "$path4/fig_1a.eps",replace 



use "$path2/marr_policy", clear
keep if  women  & age >= 25  
keep if year_birth <= 1980 & year_birth >= 1940 

recode year_birth (1940/1949 = -1) (1950/1959 = 0) (1960/1969 = 1) (1970/1980 = 2), gen(period)
tab period [aw =wt], su(senior)

collapse senior college    [aw = wt], by(period han)
reshape wide senior college  , i(period) j(han)
label define period -1 "1940-1949" 0 "1950-1959" 1 "1960-1969" 2 "1970-1980"
label value period period 
label var period "Birth Cohorts"
gr bar  senior0 senior1  college0 college1  , over(period) legend(order(2 1 4 3) label(1 "Women of Minorities (Senior high)") label(2 "Women of Han (Senior high)") label(3 "Women of Minorities (College)") label(4 "Women of Han (College)")  ring(0) pos(11) size(small)) ///
 blabel(total, format(%5.1g))  ytit("Completion rate")  ylabel(0(0.1)0.3)
gr export "$path4/fig_1b.eps", as(eps) preview(on) replace



***** Figure 2 *****

use "$path2/marr_policy", clear
keep if age > 25
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)
drop if treat == . 
keep if year == 2005 & women == 1 
gen category = 1 if han == 1 & treat == 0 
replace category = 2 if han == 1 & treat == 1 
replace category = 3 if han == 0 
replace high_occ = 0 if high_occ == . 

foreach var in "senior" "college" "late_marr" "high_occ"{
cap gen se_`var' = . 
reg `var' treat##i.year_birth if han == 1, cluster(prov)
forvalues i = 1941(1)1979{
replace se_`var' = _se[1.treat#`i'.year_birth] if year_birth == `i'
}
}

collapse senior college late_marr high_occ se_*, by(year_birth category)
reshape wide senior college late_marr high_occ se_*, i(year_birth) j(category)

foreach var in "senior" "college" "late_marr" "high_occ"{
cap drop `var'_diff up_`var' low_`var'
cap gen `var'_diff = `var'2 - `var'1
cap gen up_`var' = `var'_diff + 1.64*se_`var'1
cap gen low_`var' = `var'_diff - 1.64*se_`var'1
}

tw (con senior1 senior2 year_birth, xtit("Birth cohort") ytit("Senior high school completion rate") m(O D)) (line senior_diff year, lp(dash)  lc(blue) lw(thick)  ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(0(0.1)0.4, grid) m(O D) xline(1959 1969, lp(dash)) text(0.12 1959 "Aged 20"" in 1979") text(0.1 1969 "Aged 20"" in 1989")) ///
(line up_senior low_senior year, lp(shortdash shortdash) lc(blue blue))
gr export "$path4/fig_2a.eps",replace 


tw (con college1 college2 year_birth, xtit("Birth cohort") ytit("College completion rate") m(O D)) (line college_diff year, lp(dash) lc(blue)  lw(thick)  ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(0(0.04)0.16, grid) m(O D) xline(1959 1969, lp(dash)) text(0.1 1959 "Aged 20 ""in 1979") text(0.12 1969 "Aged 20"" in 1989")) ///
(line up_college low_college year, lp(shortdash shortdash) lc(blue blue))
gr export "$path4/fig_2b.eps",replace 

tw (con late_marr1 late_marr2 year, xtit("Birth cohort") ytit("Late marriage") m(O D))(line late_marr_diff year, lp(dash) lc(blue)  lw(thick) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(0(0.1)0.4, grid) m(O D) xline(1959 1969, lp(dash)) text(0.25 1959 "Aged 20 ""in 1979") text(0.25 1969 "Aged 20 ""in 1989")) ///
(line up_late_marr low_late_marr year, lp(shortdash shortdash) lc(blue blue))
gr export "$path4/fig_2c.eps",replace 


tw (con high_occ1 high_occ2 year, xtit("Birth cohort") ytit("White-collar job") m(O D))(line high_occ_diff year, lp(dash) lc(blue)  lw(thick) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(0(0.05)0.25, grid)  m(O D) xline(1959 1969, lp(dash)) text(0.18 1959 "Aged 20 "" in 1979") text(0.18 1969 "Aged 20"" in 1989")) ///
(line up_high_occ low_high_occ year, lp(shortdash shortdash) lc(blue blue))
gr export "$path4/fig_2d.eps",replace 


**** Figure 3 *** 

use  "$path2/ocp_uhs_reg", clear 
keep if lninc_per > 7 & lninc_per <12
keep if lnexp_per > 6.5 & lnexp_per <12
keep if lnconsump_per > 6 & lnconsump_per <11.5
drop if saving < -80 
set more off
gen head = head1 == 1 & head2 == 1
gen female_hd = women*head
egen female_hh = max(female_hd), by(dcode hcode prov year)
drop female_hd
*keep if a2 <= 2
egen fine_8_15 = rowmean(fine_age8-fine_age15)
egen fine_16_22 = rowmean(fine_age16-fine_age22)

egen fine_6_20 = rowmean(fine_age6-fine_age20)
egen fine_8_22 = rowmean(fine_age8-fine_age22)
egen fine_8_25 = rowmean(fine_age8-fine_age25)
gen smoke_wine = smoke_share + wine_share

gl FINE_VAR_4 =  "fine_6_15 fine_16_20" 
gl FINE_VAR_1 =  "fine_6_20" 

gl CONTROL_1 = "women#prov##c.year_birth women#year_birth#year" 
gl CONTROL_2 = "women#prov##c.year_birth women#year_birth#year women#prov#year" 
gl HH_STRUCTURE = "women#N_member women##c.(old_prop young_prop married female_prop)"
egen f_p = mean(women), by(dcode hcode year)
keep if age > 25 & age < 60 
keep if year_birth < 1980
g co_old = old_prop > 0 
g co_young = young_prop > 0 

gen house_owner = house_own >= 3 & house_own <= 5 if !mi(house_own)
gen food_exp = food_share - wine_share - sug_share - drink_share - resturant_share
gen sug_drink_smoke_wine = wine_share + sug_share + drink_share 


drop if han_p > 0 & han_p < 1

 
keep if han_p == 1 & women == 1
reghdfe saving c.($FINE_VAR_1) if han_p == 1  , a($CONTROL_1 $HH_STRUCTURE) res(sav_res)
gen sav_pre = saving - sav_res
gen sav_pre_noocp = saving - sav_res - fine_6_20*_b[c.fine_6_20] 
su sav_pre sav_pre_noocp
tab year, su(sav_pre)
tab year, su(sav_pre_noocp)
collapse sav_pre sav_pre_noocp, by(year_birth)
keep if year_birth >= 1950
su sav_pre sav_pre_noocp
tw con sav_pre sav_pre_noocp year_birth , legend(lab(1 "Saving rate (w/ OCP)") label(2 "Saving rate (w/o OCP)") ring(0) pos(12) col(1)) ///
xtit("Year of birth") ytit("Saving rate") m(O D) lp(solid dash) xlabel(1950(5)1980) ylabel(24(2)36)
gr export "$path4/fig_3a.eps", replace
 

use "$path2/edu_gdp.dta", clear
merge 1:1 country year using "$path2/TFR.dta", 
drop if _merge == 2 
drop _merge 

gen lngdp = ln(gdp)
drop if mi(lngdp) 
egen cid = group(country)

su cid 
local m = `r(max)'

gen k_t = .
forvalues c= 1(1)`m'{
cap reg f_t m_t if cid == `c'
cap replace k = _b[m_t] if cid == `c'

}

gen k_s = .
forvalues c= 1(1)`m'{
cap reg f m if cid == `c'
cap replace k_s = _b[m] if cid == `c'
}


replace country = "USA" if country == "United States of America"
gen gdp_2003 = gdp if year == 2003 
egen gdp_use = max(gdp_2003), by(country)
replace  lngdp = ln(gdp_use)
gen ratio = f_t/m_t
keep if pop > 1000 & lngdp > 6 

collapse k* gdp_use pop m* f* tfr, by(country)

label var k_t "Increase in female education/Increase in male education"
label var m_t "Male tertiary enrollment rate"
gen lngdp = ln(gdp_use)
keep  if !mi(gdp_use)
keep if gdp_use < 45000


tw (scatter k_t lngdp if k_t > -2 & pop > 1000 [aw = pop], m(Oh) xlabel(6(1)11)) ///
(lfit k_t lngdp if k_t > -2   [aw = pop], lp(dash) legend(off) xtit("ln(GDP per capita (PPP) 2003)")) ///
(scatter k_t lngdp if country == "China" | country == "India" | country == "Japan" | country == "USA", ml(country) msize(vsmall))
gr export "$path4/fig_3b.eps",replace 




***** Figure C1 *****
use "$path2/marr_policy", clear
set more off 
keep if year > 2000 

set more off 
replace high_occ = 0 if high_occ == . & !mi(work)
drop if women == 0 
set more off
keep if  han & age >= 25  

keep if han == 1 
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)
drop if treat == . 
gen category = 1 if han == 1 & treat == 0 
replace category = 2 if han == 1 & treat == 1 
replace category = 3 if han == 0 
replace high_occ = 0 if high_occ == . 
replace n_birth = 0 if married_ever == 0 
collapse n_birth, by(year_birth category)
reshape wide n_birth , i(year_birth) j(category)

foreach var in "n_birth"{
gen `var'_diff = `var'2 - `var'1
}
tw (con n_birth1 n_birth2 year if year_birth > 1940, xtit("Birth cohort") ytit("# of births") m(O D)) (line n_birth_diff year, yaxis(2) ytit("Difference", axis(2)) ylabel(-0.2(0.4)1, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(1) ring(0) col(1)) ylabel(0(1)4, grid) ylabel(-0.4(.2).4, axis(2)) m(O D) xline(1959 1969, lp(dash)) text(1 1959 "Aged 20 ""in 1979") text(1 1969 "Aged 20 ""in 1989"))
gr export "$path4/fig_c1a.eps",replace 


use "$path2/child_gender_mort", clear 
*keep if year >= 2000
gen wt = 1 
replace wt = 4 if year == 2005
keep if han == 1 
keep if year_birth > 1940 & year_birth < 1980
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)
/*prov == 12 | prov == 14 | prov == 15  | prov == 23 | prov == 34 | prov == 37 | prov == 50 | prov == 51 | prov == 52| prov == 63
drop if treat == .
*/
gen category = 1 if han == 1 & treat == 0 
replace category = 2 if han == 1 & treat == 1 
replace category = 3 if han == 0 
gen age = year - year_birth
reg die treat##year_birth [aw = wt], a(year)
predict death_rate

collapse death_rate [aw = wt], by(year_birth category)

reshape wide death_rate , i(year_birth) j(category)
foreach var in "death_rate"{
gen `var'_diff = `var'2 - `var'1
}
tw (con death_rate1 death_rate2 year if year > 1940, xtit("Birth cohort") ytit("Child mortality rate") m(O D)) (line death_rate_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(-0.04(0.02)0.04, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(1) ring(0) col(1)) ylabel(0(0.02).06) m(O D) xline(1959 1969, lp(dash))  text(0.04 1959 "Aged 20 ""in 1979") text(0.04 1969 "Aged 20 ""in 1989"))
gr export "$path4/fig_c1b.eps",replace 



use "$path2/child_edu", clear 
keep if han_hh == 1
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)
drop if treat == .

gen category = 1 if han == 1 & treat == 0 
replace category = 2 if han == 1 & treat == 1 
replace category = 3 if han == 0 
reg elig_edu treat##m_birth_year i.year [aw = wt], a(  age )
predict elig_edu_pre 
replace elig_edu = elig_edu_pre
reg educ treat##m_birth_year i.year [aw = wt], a(  age )
predict educ_pre 
replace educ = educ_pre
collapse elig_edu educ [aw = wt], by(m_birth_year category)

reshape wide elig_edu educ , i(m_birth_year) j(category)
foreach var in "elig_edu" "educ"{
gen `var'_diff = `var'2 - `var'1
}
keep if m_birth_year > 1940 & m_birth_year < 1980



tw (con educ1 educ2 m_birth_year if m_birth_year > 1940, xtit("Birth cohort") ytit("Education of children") m(O D)) (line educ_diff m_birth_year  if m_birth_year > 1940, yaxis(2) ytit("Difference", axis(2)) ylabel(-0.1(0.1)0.2, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(1.9(0.1)2.4, grid) m(O D) xline(1959 1969, lp(dash))  text(2 1959 "Aged 20 ""in 1979") text(2 1969 "Aged 20 in 1989"))
gr export "$path4/fig_c1c.eps",replace 



***** Figure C2 *****
set more off
set scheme s1color
use  "$path2/ocp_uhs_reg", clear 

keep if lninc_per > 7 & lninc_per <12
keep if lnexp_per > 6.5 & lnexp_per <12
keep if lnconsump_per > 6 & lnconsump_per <11.5
drop if saving < -80 
set more off
gen head = head1 == 1 & head2 == 1

keep if age > 25 & age < 60 & women == 1
keep if year_birth < 1980
g co_old = old_prop > 0 
g co_young = young_prop > 0 

gen house_owner = house_own >= 3 & house_own <= 5 if !mi(house_own)
gen food_exp = food_share - wine_share - sug_share - drink_share - resturant_share
gen sug_drink_smoke_wine = wine_share + sug_share + drink_share 

drop if han_p > 0 & han_p < 1

keep if han_p == 1 
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)

gen category = 1 if han == 1 & treat == 0 
replace category = 2 if han == 1 & treat == 1 
replace category = 3 if han == 0 
collapse co_old lninc_per lnearning_per lnexp_per lnconsump_per saving, by(category year_birth)

reshape wide co_old lninc_per lnearning_per lnexp_per lnconsump_per saving, i(year_birth) j(category)
foreach var in "co_old""lninc_per""lnearning_per""lnexp_per""lnconsump_per" "saving"{
gen `var'_diff = `var'2 - `var'1
}


tw (con lninc_per1 lninc_per2 year if year > 1940, xtit("Birth cohort") ytit("Ln income /capita") m(O D)) (line lninc_per_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(0.1(0.2)0.9, axis(2)) lp(dash) lw(thick) lc(blue) ///
 legend(lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(8(0.5)10, grid) m(O D) xline(1959 1969, lp(dash)) text(8.6 1959 "Aged 20"" in 1979")  text(8.6 1969 "Aged 20"" in 1989"))
gr export "$path4/fig_c2a.eps",replace 


tw (con lnexp_per1 lnexp_per2 year if year > 1940, xtit("Birth cohort") ytit("Ln earnings /capita") m(O D)) (line lnexp_per_diff year  if year > 1940, yaxis(2) ytit("Difference", axis(2)) ylabel(0.1(0.2)0.9, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(8(0.5)10, grid) m(O D) xline(1959 1969, lp(dash)) text(8.6 1959 "Aged 20 ""in 1979")  text(8.6 1969 "Aged 20 ""in 1989"))
gr export "$path4/fig_c2b.eps",replace 

tw (con lnconsump_per1 lnconsump_per2 year if year > 1940, xtit("Birth cohort") ytit("Ln earnings /capita") m(O D)) (line lnconsump_per_diff year  if year > 1940, yaxis(2) ytit("Difference", axis(2)) ylabel(0.1(0.2)0.9, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(8(0.5)9.5, grid) m(O D) xline(1959 1969, lp(dash)) text(8.3 1959 "Aged 20 ""in 1979")  text(8.3 1969 "Aged 20 ""in 1989"))
gr export "$path4/fig_c2c.eps",replace 


tw (con saving1 saving2  year if year > 1940, xtit("Birth cohort") ytit("Saving rate (%)") m(O D)) (line saving_diff year  if year > 1940, yaxis(2) ytit("Difference", axis(2)) ylabel(-2(4)16, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(20(5)40, grid) m(O D) xline(1959 1969, lp(dash)) text(34 1959 "Aged 20 ""in 1979") text(34 1969 "Aged 20 ""in 1989"))
gr export "$path4/fig_c2d.eps",replace 


***** Figure C3 *****
use "$path2/CFPS_OCP", clear 

cap gen men = 1-women


replace mathtest = . if mathtest<0 
replace wordtest = . if wordtest<0 

replace eduy = . if eduy >17
keep if women == 1  
gen treat = 1 if prov == 11 | prov == 13 | prov == 21 | prov == 31 | prov == 32 | prov == 33 | prov == 35 |prov == 41 | prov == 42 | prov == 43 |prov == 44 | prov == 45| prov == 46| prov == 53| prov == 64 | prov == 65
replace treat = 0 if mi(treat)

gen category = 1 if  treat == 0 
replace category = 2 if treat == 1 
collapse happy sat_marr sat_duty_other agree_women_marr agree_women_chid, by(category year_birth)
reshape wide happy sat_marr sat_duty_other agree_women_marr agree_women_chid, i(year_birth) j(category)
keep if year_birth > 1940 & year_birth < 1980
foreach v in "happy" "sat_marr" "sat_duty_other" "agree_women_marr" "agree_women_chid"{
gen `v'_diff = `v'2 - `v'1
}
tw (con sat_marr1 sat_marr2 year if year > 1940, xtit("Birth cohort") ytit("Satisfied with marraige" "(Yes = 1)") m(O D)) (line sat_marr_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(-0.2(0.2)0.6, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(.6(.1)1.1) m(O D) xline(1959 1969, lp(dash)) text(.95 1959 "Aged 20"" in 1979") text(.95 1969 "Aged 20"" in 1989"))
gr export "$path4/fig_c3a.eps", replace 

tw (con sat_duty_other1 sat_duty_other2 year if year > 1940, xtit("Birth cohort") ytit("Satisfied with spousal housework duty" "(Yes = 1)") m(O D)) (line sat_duty_other_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(-0.2(0.2)0.6, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(0(.2)1) m(O D) xline(1959 1969, lp(dash)) text(.5 1959 "Aged 20"" in 1979") text(.5 1969 "Aged 20"" in 1989"))
gr export "$path4/fig_c3b.eps", replace 

tw (con agree_women_marr1 agree_women_marr2 year if year > 1940, xtit("Birth cohort") ytit(`"Agreement with "marriage is important to women"' `"(Yes = 1)"') m(O D)) (line agree_women_marr_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(-0.2(0.2)0.6, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(.3(.1)0.9) m(O D) xline(1959 1969, lp(dash)) text(.35 1959 "Aged 20"" in 1979") text(.35 1969 "Aged 20"" in 1989"))
gr export "$path4/fig_c3c.eps", replace 

tw (con agree_women_chid1 agree_women_chid2 year if year > 1940, xtit("Birth cohort") ytit(`"Agreement with "child is important to women"' `"(Yes = 1)"') m(O D)) (line agree_women_chid_diff year  if year > 1940,  yaxis(2) ytit("Difference", axis(2)) ylabel(-0.2(0.2)0.6, axis(2)) lp(dash) lw(thick) lc(blue) ///
legend(order(2 1 3) lab(1 "Provinces w/o fines increase in 1989-1995") lab(2 "Provinces w/ fines increase in 1989-1995") lab(3 "Difference") ///
size(small) pos(11) ring(0) col(1)) ylabel(.5(.1)1.1) m(O D) xline(1959 1969, lp(dash)) text(.55 1959 "Aged 20"" in 1979") text(.55 1969 "Aged 20"" in 1989"))
gr export "$path4/fig_c3d.eps", replace 


** Figure C6 *** 

use  "$path2/ocp_uhs_reg", clear 
keep if lninc_per > 7 & lninc_per <12
keep if lnexp_per > 6.5 & lnexp_per <12
keep if lnconsump_per > 6 & lnconsump_per <11.5
drop if saving < -80 
set more off
gen head = head1 == 1 & head2 == 1
gen female_hd = women*head
egen female_hh = max(female_hd), by(dcode hcode prov year)
drop female_hd
*keep if a2 <= 2

egen f_p = mean(women), by(dcode hcode year)
keep if age > 25 & age < 60 
keep if year_birth < 1980
g co_old = old_prop > 0 
g co_young = young_prop > 0 

gen house_owner = house_own >= 3 & house_own <= 5 if !mi(house_own)
gen food_exp = food_share - wine_share - sug_share - drink_share - resturant_share
gen sug_drink_smoke_wine = wine_share + sug_share + drink_share 

drop if han_p > 0 & han_p < 1
gen run_wealth_share = run_share + wealth_in_share
gen wealth_estate_share = estate_share + wealth_share
gen gold_beauty = other_gold_share +other_beauty_share
gen food_no_wine = food_share - wine_share
gen cloth_beauty = cloth_share + other_gold + other_beauty
gen sug_drink_wine_rest = sug_drink_smoke_wine+resturant_share

preserve
keep if han_p == 1 & women == 1 

su sug_drink_wine_rest
collapse  sug_drink_wine_rest labor_share trans_in_share run_wealth_share  cons_share trans_out_share so_ins_share  wealth_estate_share sug_drink_smoke_wine food_exp ///
cloth_beauty gold_beauty cloth_share other_beauty_share resturant_share wine_share long_share food_no_wine durable_share med_share trans_comm_share edu_ent_share house_share other_real
la var labor_share "Labor earnings"
gr pie labor_share trans_in_share run_wealth_share, plabel(_all percent, size(*1.5)  color(white) format(%9.2g)) ///
 legend(label(1 "Labor earnings") label(2 "Transfer-in") label(3 "Business & Asset") ring(0) pos(1) col(1))
gr export "$path3/fig_c6a.eps",replace 

 gr pie cons_share trans_out_share so_ins_share  wealth_estate_share, plabel(_all percent,  color(white) format(%9.2g)) ///
 legend(label(1 "Consumption") label(2 "Transfer-out") label(3 "Social Insurance") label(4 "Asset & Estate") ring(0) pos(1) col(1))
gr export "$path3/fig_c6b.eps",replace 

 gr pie cloth_beauty  sug_drink_wine_rest   food_exp trans_comm_share edu_ent_share long_share house_share   med_share, plabel(_all percent,   color(white) size(  small )     format(%9.2g)) ///
 legend( label(1 "Clothing & beauty") label(2 "Drinks, sugar & restaurant")  label(3 "Food") label(4 "Trans. & comm.") label(5 "Educ. & entmt.") label(6 "Durables")  label(7 "Housing") label(8 "Medical") ///
 pos(12) row(2) size(vsmall))
gr export "$path3/fig_c6c.eps",replace 

restore 

log close 


